{include file="common/header" /}
<!-- Page body -->

    <div class="page page-center">
        <div class="container container-tight py-4">
         
          <form class="card card-md" >
            <div class="card-body">
              <h2 class="card-title text-center mb-4">用户登录</h2>
              <div class="mb-3">
                <label class="form-label">用户名</label>
                <input type="text" id="username" class="form-control" placeholder="请输入用户名">
              </div>
              <div class="mb-3">
                <label class="form-label">用户密码
                  <!-- <span class="form-label-description">
                    <a href="/index/forgetPassword">忘记密码</a>
                  </span> -->
                </label>
                <div class="input-group input-group-flat">
                  <input type="password" id="password"  class="form-control"  placeholder="请输入用户密码">
                </div>
              </div>
              
              <div class="form-footer">
                <button type="button" onclick="login()" class="btn btn-primary w-100">立即登录</button>
              </div>
            </div>
          </form>
          <!-- <div class="text-center text-secondary mt-3">
            还没有账号? <a href="/index/reg" tabindex="-1">前往注册</a>
          </div> -->
        </div>
    </div>

{include file="common/footer" /}

<script>
    function login(){
      var username = $('#username').val();
      var password = $('#password').val();
      if(username == '' || password == ''){
          layer.msg('请填写完整');return;
      }
      axios.post('/index/index/userLogin', {
        username: username,
        password: password
      })
      .then(function (res) {
        layer.msg(res.data.msg);
        if(res.data.code == 200){
          window.location.href = "/index/home/index";
        }
      })
      .catch(function (error) {
        console.log(error);
      });
  }
</script>


